home *** CD-ROM | disk | FTP | other *** search
/ CD-ROM DEMO / Zeta MultiMedia CD-ROM DEMO.iso / pc / media / main.dir / 00573_Script_objScroll < prev    next >
Text File  |  1996-09-25  |  3KB  |  100 lines

  1. property pScroll, pFond, pBouton, pConstrain
  2. property pDelta, pPosBouton, pMinScroll, pMaxScroll, pPosScroll
  3.  
  4. on birth me, sprScroll, sprFond, sprBouton, sprConstrain, dimVisible
  5.   set pScroll    = sprScroll
  6.   set pFond      = sprFond
  7.   set pBouton    = sprBouton
  8.   set pConstrain = sprConstrain
  9.   puppetSprite pScroll, TRUE
  10.   puppetSprite pBouton, TRUE
  11.   puppetSprite pConstrain, TRUE
  12.   
  13.   set dimBouton2 = (the height of sprite pBouton) / 2
  14.   spriteBox pConstrain, the left of sprite pFond, the top of sprite pFond + dimBouton2,¨
  15.                         the right of sprite pFond, the bottom of sprite pFond - dimBouton2
  16.   
  17.   set dimScroll = the height of cast the castNum of sprite pScroll - dimVisible
  18.   set dimFond = the height of cast the castNum of sprite pFond -¨
  19.                 the height of cast the castNum of sprite pBouton
  20.   
  21.   set pDelta = float (dimScroll) / float (dimFond)
  22.   set pPosBouton = the locV of sprite pBouton
  23.   
  24.   set pMaxScroll = the locV of sprite pScroll
  25.   set pMinScroll = pMaxScroll - dimScroll
  26.   set pPosScroll = the locV of sprite pScroll
  27.   return me
  28. end birth
  29.  
  30. on dispose me
  31.   puppetSprite pScroll, FALSE
  32.   puppetSprite pBouton, FALSE
  33. end dispose
  34.  
  35. on scroll me
  36.   dragMe me, pBouton
  37.   set deltaBouton = the locV of sprite pBouton - pPosBouton
  38.   set pPosBouton = the locV of sprite pBouton
  39.   set deltaScroll = pDelta * deltaBouton
  40.   delta me, deltaScroll
  41.   set pPosScroll = the locV of sprite pScroll
  42.   updateStage
  43. end scroll
  44.  
  45. on dragMe me, channel
  46.   -- save the offsets where the mouseClicked on the sprite
  47.   -- so it wonít jump during first part of the drag:
  48.   set oVtl = the locV of sprite channel - the mouseV
  49.   
  50.   --drag to a new position
  51.   repeat while the stillDown
  52.     set the locV of sprite channel to constrainV(pConstrain, the mouseV + oVtl)
  53.     updateStage
  54.   end repeat
  55. end dragMe
  56.  
  57. on delta me, deltaScroll
  58.   set resScroll = the locV of sprite pScroll - deltaScroll
  59.   set resScroll = max (min(pMaxScroll, resScroll), pMinScroll)
  60.   set realScroll = the locV of sprite pScroll - resScroll
  61.   set the locV of sprite pScroll = resScroll
  62. end delta
  63.  
  64. on updateBtn me
  65.   set deltaScroll = the locV of sprite pScroll - pPosScroll
  66.   if deltaScroll = 0 then exit
  67.   set deltaBouton = deltaScroll / pDelta
  68.   if the locV of sprite pScroll = pMinScroll then
  69.     set the locV of sprite pBouton to the bottom of sprite pConstrain
  70.   else if the locV of sprite pScroll = pMaxScroll then
  71.     set the locV of sprite pBouton to the top of sprite pConstrain
  72.   else
  73.     set the locV of sprite pBouton = pPosBouton - deltaBouton
  74.   end if
  75.   set pPosBouton = the locV of sprite pBouton
  76.   set pPosScroll = the locV of sprite pScroll
  77. end updateBtn
  78.  
  79. on upArrow me
  80.   arrow me, -1
  81. end upArrow
  82.  
  83. on downArrow me
  84.   arrow me, 1
  85. end downArrow
  86.  
  87. on arrow me, sens
  88.   set c=0
  89.   set a=sens
  90.   repeat while the stillDown
  91.     set c=c+1
  92.     if c > 4 then
  93.       set a = a + sens
  94.     end if
  95.     delta (me, a)
  96.     updateStage
  97.   end repeat
  98.   updateBtn me
  99. end arrow
  100.